package cn.wolfcode.wolf2world.web.controller;

import cn.wolfcode.wolf2world.domain.*;
import cn.wolfcode.wolf2world.service.*;
import cn.wolfcode.wolf2world.vo.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 杨兴健
 * @Date 2020/8/12 10:47
 */
@RestController
@RequestMapping("/destinations")
public class DestinationController {

    @Autowired
    private RegionService regionService;
    @Autowired
    private DestinationService destinationService;
    @Autowired
    private StrategyService strategyService;
    @Autowired
    private TravelService travelService;

    /**
     * 查询全部热门区域
     * @return
     */
    @GetMapping("/hotRegion")
    public JsonResult<Region> hotRegion() {
        return JsonResult.success(regionService.hotRegion());
    }

    /**
     * 根据区域id查询目的地，特殊处理国内-1
     * @param regionId
     * @return
     */
    @GetMapping("/search")
    public Object search(String regionId) {

        return JsonResult.success(destinationService.search(regionId));
    }

    /**
     * 吐司
     * @param destId
     * @return
     */
    @GetMapping("/toasts")
    public Object toasts(String destId) {
        return JsonResult.success(destinationService.toasts(destId));
    }

    /**
     * 目的地明细
     * @param destId
     * @return
     */
    @GetMapping("/detail")
    public Object detail(String destId) {
        return JsonResult.success(destinationService.get(destId));
    }

    /**
     * 概况 攻略分类--攻略
     * @param destId
     * @return
     */
    @GetMapping("/queryCatalog")
    public Object queryCatalog(String destId) {
        List<StrategyCatalog> list= destinationService.queryCatalog(destId);
        return JsonResult.success(list);
    }

    /**
     * 根据目的地id获取点击前三的攻略
     * @param destId
     * @return
     */
    @GetMapping("/strategies/viewnumTop3")
    public Object strategies(String destId) {
        List<Strategy> list= strategyService.strategiesViewnumTop3(destId);
        return JsonResult.success(list);
    }

    /**
     * 根据目的地id获取点击前三的游记
     * @param destId
     * @return
     */
    @GetMapping("/travels/viewnumTop3")
    public Object travels(String destId) {
        List<Travel> list= travelService.travelsViewnumTop3(destId);
        return JsonResult.success(list);
    }

    /**
     * 目的地下的攻略
     * @param destId
     * @return
     */
    @GetMapping("/catalogs")
    public Object catalogs(String destId) {

        JsonResult success = JsonResult.success(destinationService.queryCatalog(destId));
        return success;
    }



}
